﻿<UserControl x:Class="ine.Views.LoggingControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:local="clr-namespace:ine.Views"
             mc:Ignorable="d" d:DesignHeight="400" d:DesignWidth="700">
    <Grid>
        <Grid Height="30" VerticalAlignment="Bottom">
            <ToggleButton Style="{StaticResource ResourceKey=CheckBoxToggleButton}"
                          Content="Autoscroll" IsChecked="{Binding Path=AutoScrolling, Mode=OneWay}"
                          Click="HandleToggleAutoScrolling"
                          VerticalAlignment="Center" HorizontalAlignment="Right"/>
        </Grid>
        <ListView x:Name="list" Margin="0,0,0,35" ItemsSource="{Binding Path=Entries}">
            <ListView.View>
                <GridView AllowsColumnReorder="False">
                    <GridViewColumn Header="Time" Width="180">
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <TextBlock Text="{Binding Path=Time}" TextAlignment="Center"/>
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>
                    <GridViewColumn Header="Level" Width="75">
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <TextBlock Text="{Binding Path=Level}" TextAlignment="Center"/>
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>
                    <GridViewColumn Header="Message" Width="350">
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <TextBlock Text="{Binding Path=Message}" TextAlignment="Left" TextTrimming="CharacterEllipsis">
                                    <TextBlock.ToolTip>
                                        <TextBlock Text="{Binding Path=Message}"/>
                                    </TextBlock.ToolTip>
                                </TextBlock>
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>
                    <GridViewColumn Width="30" CellTemplateSelector="{Binding Path=Attachment}">
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <Button x:Name="Presenter" Click="HandleShow" 
                                        Style="{StaticResource ResourceKey=Image}"
                                        Visibility="Collapsed">
                                    <Image Initialized="HandleImageInitialized"/>
                                </Button>
                                <DataTemplate.Triggers>
                                    <DataTrigger Binding="{Binding Path=HasAttachment}" Value="True">
                                        <DataTrigger.Setters>
                                            <Setter TargetName="Presenter" Property="Visibility" Value="Visible"/>
                                        </DataTrigger.Setters>
                                    </DataTrigger>
                                </DataTemplate.Triggers>
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>
                </GridView>
            </ListView.View>
        </ListView>
    </Grid>
</UserControl>
